package com.fary.connector;

import com.fary.coyote.Adapter;
import com.fary.coyote.ProtocolHandler;
import com.fary.coyote.http11.Http11NioProtocol;

public class Connector {

    protected final ProtocolHandler protocolHandler;

    protected Adapter adapter = null;

    public Connector() {
        this.protocolHandler = new Http11NioProtocol();
    }

    protected void initInternal() {
        System.out.println("********************* Connector init");
        adapter = new CoyoteAdapter(this);
        protocolHandler.setAdapter(adapter);
        protocolHandler.init();
    }

    protected void startInternal() {
        System.out.println("********************* Connector start");
        protocolHandler.start();
    }

    public static void main(String[] args) {
        Connector connector = new Connector();
        connector.initInternal();
        connector.startInternal();
        try {
            Thread.sleep(100000000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}